﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace CatalogImporter.Utils
{
    /// <summary>
    /// Attributes CSV parser
    /// </summary>
    public class AttributesList : IDisposable, IEnumerable<Attribute>
    {
        #region Private fields

        /// <summary>
        /// The attribute enumerator
        /// </summary>
        private AttributeEnumerator enumerator;

        #endregion

        #region Constructor

        /// <summary>
        /// Constructs a new attribute CSV parser
        /// </summary>
        /// <param name="file">The file path to the product CSV</param>
        public AttributesList(String file)
        {
            this.enumerator = new AttributeEnumerator(file);
        }

        #endregion

        #region Members of IEnumerable

        public IEnumerator<Attribute> GetEnumerator()
        {
            return this.enumerator;
        }

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return this.enumerator;
        }

        #endregion

        #region Members of IDisposable

        public void Dispose()
        {
            if (this.enumerator != null)
                this.enumerator.Dispose();

            this.enumerator = null;
        }

        #endregion

    }
}
